<?
    // Initialize the session.
    session_start();
    require_once("../inc/checkAdminPagePermissions.php");
    require_once("../inc/config.inc.php");
    require_once('../conexion.php');
	function cambiafechamysql($fecha){ 
      ereg( "([0-9]{1,2})/([0-9]{1,2})/([0-9]{2,4})", $fecha, $mifecha); 
      $fechana=$mifecha[3]."-".$mifecha[2]."-".$mifecha[1]; 
      return $fechana;
     }
?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd">

<html>
<head>
    <title><? echo _SITE_NAME; ?> :: Panel Administrativo :: Inicio</title>
    <meta http-equiv=Content-Type content="text/html; charset=ISO-8859-1">
	<link href="../calendar/CalendarControl.css"      rel="stylesheet" type="text/css">
     <script src="../calendar/CalendarControl.js"        language="javascript"></script>
<SCRIPT LANGUAGE="JavaScript" SRC="../reloj/timepicker.js"></SCRIPT>
    <link href="../css/main.css" type=text/css rel=stylesheet>
	<script>
	function cerrar()
{
if (confirm("Desea salir sin aplicar los cambios ?"))
   {
    document.location="tarifas.php";
   }
}
	function valcorreo(valor) {
if (/^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/.test(valor)){
return (true)
} else {
return (false);
}
}
function isPhoneNumber(s) 
{

     // Check for correct phone number
     rePhoneNumber = new RegExp( /^\d{4}-\d{7}$/);
     if (!rePhoneNumber.test(s)) {
             return false;
     }

return true;
}
var nav4 = window.Event ? true : false;
function acceptNum(e){ 

var key;

 if(window.event) // IE
 {
  key = e.keyCode;
 }
  else if(e.which) // Netscape/Firefox/Opera
 {
  key = e.which;
 }

 if (key < 46 || key > 57) 
    {
      return false;
    }

 return true;

}

function validarnumeros(e) {
    tecla = (document.all)?e.keyCode:e.which;
    if (tecla==8) return true;
    patron = /^\d+\.?\d*$/;
	
    te = String.fromCharCode(tecla);
    return patron.test(te); 
} 
function validar(forma)
{
if (forma.peso.value=="")
{
 alert("Por favor introduzca peso");
 forma.peso.focus();
 return false;
}
if (forma.monto.value=="")
{
 alert("Por favor introduzca monto");
 forma.monto.focus();
 return false;
}

if (forma.destino.value=="")
{
 alert("Por favor introduzca destino");
 forma.destino.focus();
 return false;
}
return true;
}
function Ir() { 
  document.location="tarifas.php";
  
}
	</script>
</head>


<!-- BEGIN MAIN CONTENT ARE -->
<body style="background: #ffffff;">

<div align="left">
  <h4>Mantenimiento -> Tarifas -> Insertar Tarifa</h4>
</div>
<?php

if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
    $peso=$_POST["peso"]; 
	$monto=$_POST["monto"]; 
	$destino=$_POST["destino"]; 
	
	$cadena="INSERT INTO tarifas 
	(peso, 
	monto, 
	destino)
	VALUES
	('$peso', 
	'$monto', 
	'$destino')";
	if (@mysql_query($cadena))
	 {   echo "<script>alert('Registro actualizado');document.location='tarifas.php';</script>";
	}
   else
   {
   echo "<script>alert('Ocurrio un error actualizando el registro./n Verifique que no haya duplicado destino');window.history.back(-1);</script>";
   }

        

}
?>
<form action="insertartarifa.php" method="post" enctype="multipart/form-data" name="form1" id="form1" onSubmit="return validar(this)">
  <table width="95%" border="0" align="center" cellpadding="0" cellspacing="0">
   <tr>
	<td height="20" bgcolor="#CCCCCC"><div align="left"><strong>DATOS GENERALES</strong>&nbsp;&nbsp;&nbsp;<a class="tooltip" href="#"><img src="../images/interro.JPG" border="0"><span> <font size="-2" face="Arial, Helvetica, sans-serif">Datos generales de la tarifa.</font></span> </a>(*) Campos Obligatorios </div></td>
	</tr>
	<tr>
	<td>
	<table width="100%">
    <tr  >
      <td  ><div align="right"><strong>Peso:</strong></div></td>
      <td   colspan="1" >
        <div align="left">
          <input name="peso" type="text" id="peso" size="35" maxlength="250" onKeyPress="return validarnumeros(event)" title="Peso" style="text-align:right">
          (*)</div></td>
	    </tr>
	<tr  >
      <td  ><div align="right"><strong>Monto:</strong></div></td>
      <td >
        <div align="left">
          <input name="monto" type="text" id="monto" size="35" maxlength="250" onKeyPress="return validarnumeros(event)"  title="Monto" style="text-align:right">
          (*)</div></td>
	    </tr>
	<tr  >
      <td  ><div align="right"><strong>Destino:</strong></div></td>
      <td >
        <div align="left">
          <input name="destino" type="text" id="destino" size="35" maxlength="250" title="Destino del paquete">
          (*)</div></td>
	    </tr>
	</table>	</td>
	</tr>
	<tr>
	<td>&nbsp;</td>
	</tr>
    <tr >
      <td colspan="2" ><hr size="1" /></td>
    </tr>
    <tr >
      <td  colspan="2" align="center" ><input name="Submit" type="submit"  value="Aceptar Datos" />
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        <input name="Submit3" type="button"  onClick="cerrar()" value="Menu Tarifas" /></td>
    </tr>
  </table>
  <input type="hidden" name="MM_insert" value="form1">
 
</form>
</body>
</html>
